// 最大化窗口 最小化窗口 关闭窗口 全屏
document.body.insertAdjacentHTML('beforeend', `
    <div>
        <button onclick="maximize()">最大化</button>
        <button onclick="minimize()">最小化</button>
        <button onclick="closeWindow()">关闭</button>
        <button onclick="fullScreen()" id="fullscreen">全屏</button>
        <button onclick="restore()">恢复</button>
    </div>
    <div>
        <a href="https://ai.com" target="_blank">通过链接打开弹窗</a>
        <button onclick="window.open('https://ai.com', '_blank', 'width=500,height=400')">通过window.open打开弹窗</button>
        <button onclick="openWindow()">主进程打开普通弹窗</button>
        <button onclick="openModal()">主进程打开模态弹窗</button>
    </div>
    <div>    
        <button onclick="openUnframe()">主进程打开无边框窗口</button>
        <button onclick="openTransparent(0.5)">主进程打开透明窗口</button>
    </div>
    <div>
        <button onclick="openView()">打开内置窗口</button>
    </div>
</div>
`);

window.maximize = () => window.ipc.send('maximize');
window.minimize = () => window.ipc.send('minimize');
window.closeWindow = () => window.ipc.send('closeWindow');
window.fullScreen = () => {
    window.ipc.send('fullScreen');
    const fullscreenEl = document.getElementById('fullscreen')!;
    fullscreenEl.innerText = fullscreenEl.innerText === '全屏' ? '退出全屏' : '全屏';
};
window.restore = () => window.ipc.send('restore');
window.openWindow = () => window.ipc.send('openWindow');
window.openModal = () => window.ipc.send('openModal');
window.openUnframe = () => window.ipc.send('openUnframe');
window.openTransparent = (opacity = 0) => window.ipc.send('openTransparent', opacity);
window.openView = () => window.ipc.send('openView');
